home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / share / ewl / examples / ewl_entry_test.c < prev    next >
C/C++ Source or Header  |  2006-01-09  |  4KB  |  140 lines

  1. #include "ewl_test.h"
  2.  
  3. static Ewl_Widget *entry_button;
  4. static Ewl_Widget *entry[3];
  5.  
  6. static void
  7. __destroy_entry_test_window(Ewl_Widget * w, void *ev_data __UNUSED__,
  8.                     void *user_data __UNUSED__)
  9. {
  10.     ewl_widget_destroy(w);
  11.     ewl_callback_append(entry_button, EWL_CALLBACK_CLICKED,
  12.                 __create_entry_test_window, NULL);
  13. }
  14.  
  15. static void
  16. __fetch_entry_text(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__, 
  17.                 void *user_data __UNUSED__)
  18. {
  19.     char *s;
  20.  
  21.     s = ewl_text_text_get(EWL_TEXT(entry[0]));
  22.     if (s) {
  23.         printf("First entry covers: %s\n", s);
  24.         FREE(s);
  25.     }
  26.  
  27.     s = ewl_text_text_get(EWL_TEXT(entry[1]));
  28.     if (s) {
  29.         printf("Second entry covers: %s\n", s);
  30.         FREE(s);
  31.     }
  32.  
  33.     s = ewl_text_text_get(EWL_TEXT(entry[2]));
  34.     if (s) {
  35.         printf("Third entry covers: %s\n", s);
  36.         FREE(s);
  37.     }
  38. }
  39.  
  40. static void
  41. __set_entry_text(Ewl_Widget *w __UNUSED__, void *ev_data __UNUSED__, 
  42.                     void *user_data __UNUSED__)
  43. {
  44.     ewl_text_color_set(EWL_TEXT(entry[0]), 0, 0, 0, 255);
  45.     ewl_text_color_set(EWL_TEXT(entry[1]), 0, 0, 0, 255);
  46.     ewl_text_color_set(EWL_TEXT(entry[2]), 0, 0, 0, 255);
  47.  
  48.     ewl_text_text_set(EWL_TEXT(entry[0]), "Play with me ?");
  49.     ewl_text_text_set(EWL_TEXT(entry[1]), "E W L ! ! !");
  50.  
  51.     ewl_text_clear(EWL_TEXT(entry[2]));
  52. }
  53.  
  54. void
  55. __create_entry_test_window(Ewl_Widget *w, void *ev_data __UNUSED__, 
  56.                         void *user_data __UNUSED__)
  57. {
  58.     Ewl_Widget *entry_win;
  59.     Ewl_Widget *entry_box;
  60.     Ewl_Widget *button_hbox, *o;
  61.     Ewl_Widget *button[2];
  62.  
  63.     entry_button = w;
  64.  
  65.     entry_win = ewl_window_new();
  66.     ewl_window_title_set(EWL_WINDOW(entry_win), "Entry Test");
  67.     ewl_window_name_set(EWL_WINDOW(entry_win), "EWL Test Application");
  68.     ewl_window_class_set(EWL_WINDOW(entry_win), "EFL Test Application");
  69.  
  70.     if (w) {
  71.         ewl_callback_del(w, EWL_CALLBACK_CLICKED, 
  72.                     __create_entry_test_window);
  73.         ewl_callback_append(entry_win, EWL_CALLBACK_DELETE_WINDOW,
  74.                     __destroy_entry_test_window, NULL);
  75.     } else
  76.         ewl_callback_append(entry_win, EWL_CALLBACK_DELETE_WINDOW,
  77.                     __close_main_window, NULL);
  78.     ewl_widget_show(entry_win);
  79.  
  80.     /*
  81.      * Create the main box for holding the widgets
  82.      */
  83.     entry_box = ewl_vbox_new();
  84.     ewl_container_child_append(EWL_CONTAINER(entry_win), entry_box);
  85.     ewl_box_spacing_set(EWL_BOX(entry_box), 10);
  86.     ewl_widget_show(entry_box);
  87.  
  88.     entry[0] = ewl_entry_new();
  89.     ewl_text_text_set(EWL_TEXT(entry[0]), "Play with me ?");
  90.     ewl_entry_multiline_set(EWL_ENTRY(entry[0]), 1);
  91.     ewl_text_color_set(EWL_TEXT(entry[0]), 255, 0, 0, 255);
  92.     ewl_object_padding_set(EWL_OBJECT(entry[0]), 5, 5, 5, 0);
  93.     ewl_container_child_append(EWL_CONTAINER(entry_box), entry[0]);
  94.     ewl_widget_show(entry[0]);
  95.  
  96.     entry[1] = ewl_entry_new();
  97.     ewl_text_text_set(EWL_TEXT(entry[1]), "E W L ! ! !");
  98.     ewl_text_color_set(EWL_TEXT(entry[1]), 255, 0, 0, 255);
  99.     ewl_object_padding_set(EWL_OBJECT(entry[1]), 5, 5, 0, 0);
  100.     ewl_container_child_append(EWL_CONTAINER(entry_box), entry[1]);
  101.     ewl_widget_show(entry[1]);
  102.  
  103.     entry[2] = ewl_entry_new();
  104.     ewl_object_padding_set(EWL_OBJECT(entry[2]), 5, 5, 0, 0);
  105.     ewl_container_child_append(EWL_CONTAINER(entry_box), entry[2]);
  106.     ewl_widget_show(entry[2]);
  107.  
  108.     button_hbox = ewl_hbox_new();
  109.     ewl_object_alignment_set(EWL_OBJECT(button_hbox), EWL_FLAG_ALIGN_CENTER);
  110.     ewl_container_child_append(EWL_CONTAINER(entry_box), button_hbox);
  111.     ewl_box_spacing_set(EWL_BOX(button_hbox), 5);
  112.     ewl_widget_show(button_hbox);
  113.  
  114.     button[0] = ewl_button_new();
  115.     ewl_button_label_set(EWL_BUTTON(button[0]), "Fetch text");
  116.     ewl_container_child_append(EWL_CONTAINER(button_hbox), button[0]);
  117.     ewl_callback_append(button[0], EWL_CALLBACK_CLICKED,
  118.                 __fetch_entry_text, NULL);
  119.     ewl_widget_show(button[0]);
  120.  
  121.     button[1] = ewl_button_new();
  122.     ewl_button_label_set(EWL_BUTTON(button[1]), "Set Text");
  123.     ewl_container_child_append(EWL_CONTAINER(button_hbox), button[1]);
  124.     ewl_callback_append(button[1], EWL_CALLBACK_CLICKED,
  125.                 __set_entry_text, NULL);
  126.     ewl_widget_show(button[1]);
  127.  
  128.     o = ewl_label_new();
  129.     ewl_label_text_set(EWL_LABEL(o), "Text insert \"\"");
  130.     ewl_container_child_append(EWL_CONTAINER(button_hbox), o);
  131.     ewl_widget_show(o);
  132.  
  133.     o = ewl_text_new();
  134.     ewl_text_text_set(EWL_TEXT(o), "");
  135.     ewl_container_child_append(EWL_CONTAINER(button_hbox), o);
  136.     ewl_widget_show(o);
  137. }
  138.  
  139.  
  140.